package com.yipao.wx.web.goods;

import com.yipao.core.constant.GlobalConstant;
import com.yipao.core.util.ResponseUtil;
import com.yipao.core.validator.Order;
import com.yipao.core.validator.Sort;
import com.yipao.db.domain.goods.vo.GoodsMaterialReq;
import com.yipao.db.service.goods.GoodsMaterialService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 商品原料
 *
 * @author tianhao
 * @date 2020/4/29 18:27
 **/
@RestController
@RequestMapping("/wx/goods/material")
@Validated
public class WxGoodsMaterialController {
    @Resource
    private GoodsMaterialService goodsMaterialService;


    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       @Sort @RequestParam(defaultValue = "add_time") String sort,
                       @Order @RequestParam(defaultValue = "desc") String order) {
        return ResponseUtil.okList(goodsMaterialService.selectByExample(
                new GoodsMaterialReq(page, limit, sort, order, GlobalConstant.DeleteStatus.NOT_DELETED)));
    }
}
